public class Solution507 {
    public boolean checkPerfectNumber(int num) {
        int ans=0;
        for (int i=1;i*i<=num;i++){
            if (num%i==0){
                ans=ans+i+num/i;
                if (i*i==num){
                    ans-=i;
                }
            }
        }
        return ans==num*2?true:false;
    }

    public static void main(String[] args) {
        System.out.println(new Solution507().checkPerfectNumber(28));
    }
}
